package com.caicai.dubbo.consumer.caicaidubboconsumer;

import cmo.caicai.service.UserInfoService;
import com.caicai.domain.User;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@SpringBootApplication
@RestController
@EnableDubbo
public class CaicaiDubboConsumerApplication {

	@Reference
	private static UserInfoService userInfoService;


	private static ConsumerService consumerService;

	@Autowired
	public  void setConsumerService(ConsumerService consumerService) {
		CaicaiDubboConsumerApplication.consumerService = consumerService;
	}

	@RequestMapping(value = "/getDubboServer",method = RequestMethod.GET)
	public User getDubboServer(){

		return userInfoService.findById("1");
	}

	@RequestMapping(value = "/test",method = RequestMethod.GET)
	public User test(){

		return consumerService.findById("1");
	}

	public static void main(String[] args) {
		SpringApplication.run(CaicaiDubboConsumerApplication.class, args);
	}

}
